#*-- coding:utf-8 --*
import xml.dom.minidom as minidom
from xml.dom.minidom import Node
from  base64 import *

doc = minidom.parse("mail_k.xml")

print 'reading'

for node in doc.getElementsByTagName("mail_k"):
    type_id = node.getElementsByTagName("type_id")[0].childNodes[0].data
    type_memo = b64decode(node.getElementsByTagName("type_memo")[0].childNodes[0].data)
    print 'writing %s_' % type_id
    f = open('%s.mdb' % type_id, 'wb')
    f.write(type_memo)
    f.close()
    print 'finished'
print 'press anykey'
raw_input()
    
    
    
    
    
    
    

